package com.bdqn.config.exception;

import jakarta.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(UnauthorizedException.class)
    public ModelAndView unauthenticatedException(HttpServletRequest request, UnauthorizedException e) {
        ModelAndView modelAndView = new ModelAndView("403");
        modelAndView.addObject("exception",e);
        modelAndView.addObject("url",request.getRequestURL());
        return modelAndView;
    }
}
